package com.villaday.idf.adapter3;

import android.content.Context;
import android.view.View;

import com.villaday.idf.R;
import com.villaday.idf.base.AbsRecyclerViewAdapter;
import com.villaday.idf.base.OnAdapterCallbackListener;
import com.villaday.idf.model.VipsMemberOrders;
import com.villaday.idf.model3.DataEntity;
import com.villaday.idf.model3.HashHousesEntity;

public class MyWineShopAdapter extends AbsRecyclerViewAdapter<HashHousesEntity.BodyBean.ListBean> {

    View.OnClickListener onClickListener;
    private OnAdapterCallbackListener onAdapterCallbackListener;

    public MyWineShopAdapter(Context context, OnAdapterCallbackListener onAdapterCallbackListener, View.OnClickListener onClickListener) {
        super(context, R.layout.recycle_my_wine_shop, R.layout.item_page_loading,R.layout.item_page_bottom);
        this.onAdapterCallbackListener = onAdapterCallbackListener;
        this.onClickListener = onClickListener;
    }

    @Override
    public int getItemType(HashHousesEntity.BodyBean.ListBean d) {
        return d.getShowType();
    }

    @Override
    public void onBindHolder(AbsRecyclerViewAdapter.RecyclerViewHolder holder, HashHousesEntity.BodyBean.ListBean d, int position) {
        switch (d.getShowType()){
            case 0:
                holder.bindTextView(R.id.tv_mws_title, d.getName())
                        .bindSimpleDraweeView(R.id.sdv_mws, d.getImageUrl())
                        .bindTextView(R.id.tv_mws_address, d.getAddress());


                if (d.getPermission().isAllowPriceManage()) {
                    holder.getView(R.id.tv_mws_left).setVisibility(View.VISIBLE);
                } else {
                    holder.getView(R.id.tv_mws_left).setVisibility(View.GONE);
                }
                if (d.getPermission().isAllowStateManage()) {
                    holder.getView(R.id.tv_mws_right).setVisibility(View.VISIBLE);
                } else {
                    holder.getView(R.id.tv_mws_right).setVisibility(View.GONE);
                }

                holder.getView(R.id.tv_mws_left).setTag(position);
                holder.getView(R.id.tv_mws_left).setOnClickListener(onClickListener);
                holder.getView(R.id.tv_mws_right).setTag(position);
                holder.getView(R.id.tv_mws_right).setOnClickListener(onClickListener);
                break;
            case 1:
                onAdapterCallbackListener.onCallback();
                break;
        }
    }
}
